var chart;
function pie(libelle, valeur, pc_name){
	$(document).ready(function() {
	   chart = new Highcharts.Chart({
	      chart: {
	         renderTo: 'pie_container',
	         plotBackgroundColor: null,
	         plotBorderWidth: null,
	         theme: 'grid',
	         plotShadow: false
	      },
	      title: {
	         text: 'Répartition des anomalies du ' + pc_name
	      },
	      tooltip: {
	         formatter: function() {
	            return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
	         }
	      },
	      plotOptions: {
	         pie: {
	            allowPointSelect: true,
	            cursor: 'pointer',
	            dataLabels: {
	               enabled: true
	            },
	            showInLegend: true
	         }
	      },
	       series: [{
	         type: 'pie',
	         name: 'Répartition des anomalies',
	         data: calcul(libelle, valeur)
	      }]
	   });
	});
}

function calcul(libelle, valeur) {
	var data = [], i;
	for (i = 0; i < libelle.length; i++) {
		data.push({
			name: libelle[i],
		    y: valeur[i]
		});
	}
	return data;
}
